package com.lh.mybatisuse.service.Impl;

import com.lh.mybatisuse.dao.ZoneMapper;
import com.lh.mybatisuse.dto.ZoneDto;
import com.lh.mybatisuse.model.InPutParam.ZoneInParam;
import com.lh.mybatisuse.model.InPutParam.ZoneInsertInParam;
import com.lh.mybatisuse.model.ZoneModel;
import com.lh.mybatisuse.service.ZoneService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：梁昊，后端工程师：梁昊
 * @create 2021-06-22 17:11
 * @function
 * @editLog
 */
@SuppressWarnings("SpringJavaInjectionPointsAutowiringInspection")
@Service
public class ZoneServiceImpl implements ZoneService {
    @Autowired
    ZoneMapper zoneMapper;
    /**
     * 根据级别查询不分页
     *
     * @param zoneInParam com.lh.mybatisuse.model.InPutParam.ZoneInParam
     * @return 行政区划
     */
    @Override
    public List<ZoneModel> selectZone(ZoneInParam zoneInParam) {
        return zoneMapper.selectZone(zoneInParam);
    }


    /**
     * 增加一条记录
     *
     * @param zoneInsertInParam com.lh.mybatisuse.model.InPutParam.ZoneInsertInParam
     * @return 行政区划
     */
    @Override
    public int insertZoneAllInfo (ZoneInsertInParam zoneInsertInParam) {
        if (zoneMapper.insertZoneAllInfoBeforeCheck(zoneInsertInParam) == 0)
            return zoneMapper.insertZoneAllInfo(zoneInsertInParam);
        else
            return -1000;
    }

    /**
     * 增加一条记录
     *
     * @param zoneInsertInParam com.lh.mybatisuse.model.InPutParam.ZoneInsertInParam
     * @return 行政区划
     */
    @Override
    public int insertZoneAllInfoBeforeCheck(ZoneInsertInParam zoneInsertInParam) {
        return zoneMapper.insertZoneAllInfoBeforeCheck(zoneInsertInParam);
    }

    /**
     * 查询省与城市
     *
     * @param provinceLabel 地区名称
     * @return 行政区划
     */
    @Override
    public List<ZoneDto> selectZoneAndCityByProId(String provinceLabel) {
        return zoneMapper.selectZoneAndCityByProId(provinceLabel);
    }

}